package myky.com.doctorapp.adapter;

import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.facebook.drawee.view.SimpleDraweeView;
import com.github.nukc.stateview.Constant;

import java.util.List;

import myky.com.doctorapp.R;
import myky.com.doctorapp.api.Address;
import myky.com.doctorapp.entity.HealthEntity;
import myky.com.doctorapp.utils.UriUtils;




/**
 * Title:首页健康资讯的适配器
 * Description: TODO
 * @author xiangyao
 * date 2019/1/14
 */
public class DoctorArtcalAdapter extends BaseQuickAdapter<HealthEntity.PayLoadBean.ArticleListBean, BaseViewHolder> {
    public DoctorArtcalAdapter(@Nullable List<HealthEntity.PayLoadBean.ArticleListBean> data) {
        super(R.layout.doctor_lecture_item, data);
    }

    @Override
    protected void convert(BaseViewHolder holder, HealthEntity.PayLoadBean.ArticleListBean articleListBean) {

        HealthEntity.PayLoadBean.ArticleListBean.DoctorBean doctor = articleListBean.getDoctor();
        if (doctor != null) {
            holder.setText(R.id.doctor_lecture_item_realName, doctor.getRealname());
            holder.setText(R.id.doctor_lecture_item_hospital, doctor.getHospital());
            holder.setText(R.id.doctor_lecture_item_level, doctor.getDoctoracademic());
        }

        holder.setText(R.id.doctor_lecture_item_date, articleListBean.getCreatetime());
        holder.setText(R.id.doctor_lecture_item_text, articleListBean.getTitle());

        SimpleDraweeView imageView = holder.getView(R.id.doctor_lecture_item_header);
        ImageView iv = holder.getView(R.id.doctor_lecture_item_iv);
        final List<String> md5List = articleListBean.getResource();
        iv.setImageURI(UriUtils.getUriInstance().getUri(Constant.ONLINEPIC,Address.IMAGE + md5List.get(0)));
        imageView.setImageURI(UriUtils.getUriInstance().getUri(Constant.ONLINEPIC, Address.IMAGE+doctor.getHeadPhoto()));
        holder.addOnClickListener(R.id.rootLayout);
    }
}

